using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Spinning.Spinning.Unitity;
using Microsoft.Xna.Framework;

namespace Spinning.Spinning.Entity
{
    public class Sprite:BaseEntity
    {
        public Texture2D _texture;
        public string textureName;

        public Sprite():base() {
            Color = Microsoft.Xna.Framework.Color.White;
            Scale = new Microsoft.Xna.Framework.Vector2(1);
            Alpha = 1;
            Static = false;
        }

        public override void OnLoad()
        {
            if (textureName.Length == 0)
                throw new Exception("textureName");
            ResourceManager.ContentRoot = "Images";
            _texture = ResourceManager.LoadTexture2D(textureName);
        }

        protected override void DrawSelf(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Microsoft.Xna.Framework.GameTime gameTime)
        {
            base.DrawSelf(spriteBatch, gameTime);
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Projection);
            spriteBatch.Draw(_texture, Position, null, this.Color, Rotation,Origin*new Vector2(_texture.Width,_texture.Height), Scale, SpriteEffects.None, 0);
            spriteBatch.End();
        }

        public Vector2 SpriteSize { get { return new Vector2(_texture.Width, _texture.Height); } }

    }
}
